<template>
  <div class="user">
    <div class="top">
      <el-button type="primary">+ 新增</el-button>
      <div class="search">
        <el-input placeholder="请输入用户名" v-model="search" class="input">
          <el-button slot="append" icon="el-icon-search"></el-button>
        </el-input>
      </div>
    </div>
    <div class="table">
      <el-table :data="tableData" style="width: 100%" :border="true">
        <el-table-column prop="classId" width="100" label="classId" align="center"></el-table-column>
        <el-table-column prop="className" label="用户名" width="200" align="center"></el-table-column>
        <el-table-column prop="status" label="状态" width="100" align="center"></el-table-column>
        <el-table-column prop="createTime" label="创建时间" width="200" align="center">
          <template slot-scope="scoped">{{scoped.row.createTime | timer}}</template>
        </el-table-column>
        <el-table-column prop="updateTime" label="更新时间" width="200" align="center"></el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
            <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
<script>
import { getClassfy } from "@/api";
export default {
  data() {
    return {
      search: "",
      currentPage: 1,
      tableData: []
    };
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    getClassfy() {
      getClassfy().then(data => {
        console.log(data);
        if (data.code == 200 && data.msg == "成功") {
          this.tableData = data.data;
        }
      });
    }
  },
  created() {
    this.getClassfy();
  }
};
</script>
<style lang="less" scoped>
.user {
  .top {
    width: 100%;
    height: 50px;
    margin-top: 40px;
    padding: 0 30px;
    box-sizing: border-box;
    .el-button {
      float: left;
    }
    .search {
      float: right;
      .input /deep/ .el-input__inner {
        border: 1px solid #ccc;
        outline: none;
      }
    }
  }
  .table {
    border: 1px solid #ccc;
  }
  .page {
    .el-pagination {
      width: 300px;
      margin-left: 300px;
      margin-top: 50px;
      margin-bottom: 50px;
    }
  }
}
</style>